// page/my/recommend.js
var app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		recommendList: []
	},
	page: 1,

	onShow: function() {
		let token = wx.getStorageSync('token') || '';
		console.log(token);
		if (!app.globalData.userInfo) {
			app.error("请登录后再操作", function() {
				setTimeout(function() {
					wx.navigateBack({})
				}, 2000);
			});
		}
	},
	
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		this.page = 1;
		this.getRecommendList();
		console.log("after page:",this.page);
	},

	getRecommendList(){
		let token = wx.getStorageSync('token') || '';
		
		console.log("before page:", this.page);
		
		console.log("请求" + token);
		
		var that = this;
		app.request('/user/recommendList', {
			token: token,
			page: 0
		}, function(data, ret) {
			console.log(data);
			that.setData({
				recommendList: data.recommendList
			});
			that.page++;
		}, function(data, ret) {
			that.error(ret.msg);
		});
	
	}
})
